home *** CD-ROM | disk | FTP | other *** search
- #include <MacTypes.h>
-
- #define OLDROUTINELOCATIONS 0
- #define OLDROUTINENAMES 0
- #define SystemSevenOrLater 1
-
- #ifndef __FONTS__
- # include <Fonts.h>
- #endif
-
- #ifndef __DIALOGS__
- # include <Dialogs.h>
- #endif
-
- #ifndef __LOWMEM__
- # include <LowMem.h>
- #endif
-
-
- static pascal OSErr InitMac (void)
- {
- MaxApplZone ( );
- InitGraf (&(qd.thePort));
- InitFonts ( );
- InitWindows ( );
- InitMenus ( );
- TEInit ( );
- InitDialogs (nil);
-
- return noErr;
- }
-
- static GetNextEventFilterUPP gGetNextEventFilterUPP;
- static Boolean gFilterDone;
-
- enum { kNumStamps = 4 };
-
- unsigned long timeStamps[kNumStamps];
- static int timeStampIndex = 0;
- static int lastTime = 0;
- static int numEvents = 0;
- Boolean gRefresh = 0;
-
- static GetNextEventFilterUPP myFilterUPP = nil;
-
- void doRefreshMenuBar()
- {
- gRefresh = 1;
- }
-
- static unsigned long GetMSTicks()
- {
- Duration tix;
- unsigned long long time;
-
- Microseconds((UnsignedWide*) &time);
-
- tix = (time / 1000);
-
- return tix;
- }
-
- static void myGetNextEventFilter (EventRecord *event, Boolean *result)
- {
- // measure time between null events
- //if (event->what != nullEvent)
- {
- numEvents++;
- }
-
- if (gRefresh || event->what == mouseUp || event->what == keyUp)
- {
- gRefresh = 0;
- DrawMenuBar();
- }
-
- if (gGetNextEventFilterUPP)
- CallGetNextEventFilterProc(gGetNextEventFilterUPP, event, result);
-
- }
-
-
- int jGNECount()
- {
- int i;
- int count = numEvents;
-
- numEvents = 0;
- return count;
- }
-
- void InstalljGNE()
- {
- int i;
- myFilterUPP = NewGetNextEventFilterProc (myGetNextEventFilter);
-
- for (i = 0; i < kNumStamps; i++)
- {
- timeStamps[i] = 0;
- }
-
- if (myFilterUPP)
- {
- gGetNextEventFilterUPP = LMGetGNEFilter ( );
- LMSetGNEFilter (myFilterUPP);
- }
- }
-
- void RemovejGNE()
- {
- if (LMGetGNEFilter ( ) == myFilterUPP)
- LMSetGNEFilter (gGetNextEventFilterUPP);
-
- DisposeRoutineDescriptor (myFilterUPP);
- }
-
- /*void main (void)
- {
- if (!InitMac ( ))
- {
- GetNextEventFilterUPP myFilterUPP = NewGetNextEventFilterProc (myGetNextEventFilter);
-
- if (myFilterUPP)
- {
- gGetNextEventFilterUPP = LMGetGNEFilter ( );
- LMSetGNEFilter (myFilterUPP);
-
- do
- {
- EventRecord event;
- WaitNextEvent (everyEvent,&event,1,nil);
- }
- while (!gFilterDone);
-
- if (LMGetGNEFilter ( ) != myFilterUPP)
- DebugStr ("\pSomeone else has gotten into the jGNE filter chain!");
- else
- LMSetGNEFilter (gGetNextEventFilterUPP);
-
- DisposeRoutineDescriptor (myFilterUPP);
- }
- }
- }
- */
-